# -*- coding=utf-8 -*-
# @Time    : 2021/3/4 13:06
# @Author  : lhys
# @FileName: major.py

myName = r'''
    Welcome, my master!
    My Name is :
     ____                ____        ____        ____         ____              ______________
    |    |              |    |      |    |      |    \       /    |           /              /
    |    |              |    |      |    |      |     \     /     |          /              /
    |    |              |    |      |    |      |      \   /      |         /              /
    |    |              |    |      |    |       \      \_/      /         /       _______/
    |    |              |    |______|    |        \             /          \            \
    |    |              |                |         \           /            \            \
    |    |              |     ______     |          \         /              \            \
    |    |              |    |      |    |           \       /                \________    \
    |    |              |    |      |    |            |     |               /              /
    |    |_______       |    |      |    |            |     |              /              /
    |            |      |    |      |    |            |     |             /              /
    |____________|      |____|      |____|            |_____|            /______________/
    '''
print(myName)
import tkinter as tk
from tools import *

win = tk.Tk()
win.title('计算器')

entry_frame = tk.Frame(win)
menu_frame = tk.Frame(win)
major_frame = tk.Frame(win)
cal_frame = tk.Frame(win)

entry_frame.pack(side="top")
menu_frame.pack(side="left")
major_frame.pack()
cal_frame.pack()

# 输入框
t_label = tk.Label(entry_frame, text = "请输入 : ")
t_label.pack(side='left')
word_entry = tk.Entry(
    entry_frame,
    fg = "blue",
    bd = 3,
    width = 39,
    justify = 'right'
)
word_entry.pack()


# 菜单栏
for char in ['+', '-', '×', '÷']:
    myButton(menu_frame, char, word_entry)

button_side = ['right', 'left']

for i in range(4):
    num_frame = tk.Frame(major_frame)
    num_frame.pack()
    if i < 3:
        for count in range(3*i+1, 3*i+4):
            myButton(num_frame, count, word_entry, side=(i, count))
        continue
    myButton(num_frame, 0, word_entry, side=(i, 0))

reset_btn = tk.Button(
    cal_frame,
    text = '重置',
    activeforeground = "blue",
    activebackground = "pink",
    width = "13",
    command = lambda :word_entry.delete(0, "end")
).pack(side="left")
result_btn = tk.Button(
    cal_frame,
    text = '=',
    activeforeground = "blue",
    activebackground = "pink",
    width = "13",
    command = lambda :calculate(word_entry)
).pack(side="right")

win.mainloop()
